Skip to main content

Class ObservableBase<UNIT>

Provides observable functionality.

Keeps an internal collection of observers, and provides methods such as NotifyObservers and Subscribe.

Assembly: Meadow.Foundation.dll
View Source
Declaration
public abstract class ObservableBase<UNIT> : IObservable<IChangeResult<UNIT>> where UNIT : struct

Derived:
Meadow.Foundation.SamplingSensorBase<UNIT>

Implements:
System.IObservable<Meadow.IChangeResult<<UNIT>>>

Properties

observers

Subscribed observers

View Source
Declaration
protected List<IObserver<IChangeResult<UNIT>>> observers { get; set; }

Methods

NotifyObservers(IChangeResult<UNIT>)

Notify observers of a change

View Source
Declaration
protected void NotifyObservers(IChangeResult<UNIT> changeResult)
Parameters
TypeName
Meadow.IChangeResult<<UNIT>>changeResult

Subscribe(IObserver<IChangeResult<UNIT>>)

Subscribes an IObserver to get notified when a change occurs.

View Source
Declaration
public IDisposable Subscribe(IObserver<IChangeResult<UNIT>> observer)
Returns

System.IDisposable

Parameters
TypeNameDescription
System.IObserver<Meadow.IChangeResult<<UNIT>>>observerThe IObserver that will receive the
change notifications.

CreateObserver(Action<IChangeResult<UNIT>>, Predicate<IChangeResult<UNIT>>?)

Convenience method to generate a an FilterableChangeObserver with the correct signature.

View Source
Declaration
public static FilterableChangeObserver<UNIT> CreateObserver(Action<IChangeResult<UNIT>> handler, Predicate<IChangeResult<UNIT>>? filter = null)
Returns

Meadow.FilterableChangeObserver<<UNIT>>: A FilterableChangeObserver

Parameters
TypeNameDescription
System.Action<Meadow.IChangeResult<<UNIT>>>handlerThe action that is invoked when the filter is satisfied.
System.Predicate<Meadow.IChangeResult<<UNIT>>>filterAn optional filter that determines whether or not the
consumer should be notified.

Implements

  • System.IObservable<Meadow.IChangeResult<<UNIT>>>